<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="120px"
    >
      <el-form-item label="提现人会员号" prop="custNo">
        <el-input
          v-model="queryParams.custNo"
          placeholder="请输入提现人会员号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="提现人姓名" prop="realName">
        <el-input
          v-model="queryParams.realName"
          placeholder="请输入提现人姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="联系方式" prop="mobile">
        <el-input
          v-model="queryParams.mobile"
          placeholder="请输入联系方式"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="银行卡号" prop="bankCard">
        <el-input
          v-model="queryParams.bankCard"
          placeholder="请输入银行卡号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="推送到第三方唯一 ID" prop="outTradeNo">
        <el-input
          v-model="queryParams.outTradeNo"
          placeholder="请输入推送到第三方唯一 ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="完成日期" prop="closeDt">
        <!-- <el-input
          v-model="queryParams.closeDt"
          placeholder="请输入完成日期"
          clearable
          @keyup.enter.native="handleQuery"
        /> -->
        <el-date-picker
          v-model="form.closeDt"
          type="date"
          placeholder="请选择完成日期"
          format="yyyy-MM-dd"
          value-format="yyyy-MM-dd"
          style="width: 215px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="创建时间" prop="createDt">
        <el-input
          v-model="queryParams.createDt"
          placeholder="请输入创建时间"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item label="服务商审批状态" prop="srvCheck">
        <!-- <el-input
          v-model="queryParams.srvCheck"
          placeholder="请输入服务商审批状态【0 审核中 1 已审核 2 已拒绝】"
          clearable
          @keyup.enter.native="handleQuery"
        /> -->
        <el-select
          v-model="form.srvCheck"
          clearable
          placeholder="请选择"
          style="width: 100%"
          @keyup.enter.native="handleQuery"
        >
          <el-option
            v-for="dict in dict.type.srv_check"
            :key="dict.value"
            :label="dict.label"
            :value="parseInt(dict.value)"
          />
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="服务商拒绝原因" prop="srvRefuseRemark">
        <el-input
          v-model="queryParams.srvRefuseRemark"
          placeholder="请输入服务商拒绝原因"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="服务商审批操作时间" prop="srvCheckDt">
        <el-input
          v-model="queryParams.srvCheckDt"
          placeholder="请输入服务商审批操作时间"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['api:getcash:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['api:getcash:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['api:getcash:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['api:getcash:export']"
          >导出</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="getcashList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column
        label="主键id"
        align="center"
        prop="id"
        min-width="120"
        show-overflow-tooltip
      />
      <el-table-column
        label="提现人会员号"
        align="center"
        prop="custNo"
        min-width="120"
        show-overflow-tooltip
      />
      <el-table-column
        label="提现人姓名"
        align="center"
        prop="realName"
        min-width="100"
        show-overflow-tooltip
      />
      <el-table-column
        label="会员级别"
        align="center"
        prop="custType"
        min-width="120"
      >
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.sys_cust_type"
            :value="scope.row.custType"
          />
        </template>
      </el-table-column>
      <el-table-column
        label="联系方式"
        align="center"
        prop="mobile"
        min-width="140"
      />
      <el-table-column
        label="提现金额"
        align="center"
        prop="amount"
        min-width="100"
      />
      <el-table-column
        label="固定手续费"
        align="center"
        prop="tax"
        min-width="120"
      />
      <el-table-column
        label="按比例手续费"
        align="center"
        prop="srvFee"
        min-width="120"
      />
      <el-table-column
        label="实际到帐金额"
        align="center"
        prop="actualAmount"
        min-width="120"
      />
      <el-table-column label="打款类型" align="center" prop="recvType">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.recv_type"
            :value="scope.row.recvType"
          />
        </template>
      </el-table-column>
      <el-table-column
        label="提现人身份证号"
        align="center"
        prop="custCardno"
        min-width="160"
        show-overflow-tooltip
      />
      <el-table-column
        label="收款银行"
        align="center"
        prop="bankName"
        min-width="120"
        show-overflow-tooltip
      />
      <el-table-column
        label="银行卡号"
        align="center"
        prop="bankCard"
        min-width="120"
        show-overflow-tooltip
      />
      <el-table-column
        label="银行卡所有者"
        align="center"
        prop="bankCardUnt"
        min-width="120"
        show-overflow-tooltip
      />
      <el-table-column
        label="处理状态"
        align="center"
        prop="status"
        min-width="120"
      >
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.processing_status"
            :value="scope.row.status"
          />
        </template>
      </el-table-column>
      <el-table-column
        label="审核操作人用户号"
        align="center"
        prop="userName"
        min-width="120"
        show-overflow-tooltip
      />
      <el-table-column
        label="撤销原因"
        align="center"
        prop="statusErr"
        min-width="120"
        show-overflow-tooltip
      />
      <el-table-column
        label="审核时间"
        align="center"
        prop="checkDt"
        min-width="160"
      />
      <el-table-column
        label="银行卡开卡省份"
        align="center"
        prop="bankProvince"
        min-width="120"
        show-overflow-tooltip
      />
      <el-table-column
        label="银行卡开卡城市"
        align="center"
        prop="bankCity"
        min-width="120"
        show-overflow-tooltip
      />
      <el-table-column
        label="签约唯一编号"
        align="center"
        prop="employeeId"
        min-width="120"
        show-overflow-tooltip
      />
      <el-table-column
        label="推送到第三方唯一 ID"
        align="center"
        prop="outTradeNo"
        min-width="120"
        show-overflow-tooltip
      />
      <el-table-column
        label="关联转账单id"
        align="center"
        prop="transferId"
        min-width="120"
        show-overflow-tooltip
      />
      <el-table-column
        label="完成日期"
        align="center"
        prop="closeDt"
        min-width="160"
      />
      <el-table-column
        label="创建时间"
        align="center"
        prop="createDt"
        min-width="160"
      />
      <el-table-column
        label=" 备注"
        align="center"
        prop="remark"
        min-width="160"
        show-overflow-tooltip
      />
      <el-table-column
        label="结算备注"
        align="center"
        prop="settRemark"
        min-width="160"
        show-overflow-tooltip
      />
      <el-table-column label="服务商审批状态" align="center" prop="srvCheck">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.srv_check"
            :value="scope.row.srvCheck"
          />
        </template>
      </el-table-column>
      <el-table-column
        label="服务商拒绝原因"
        align="center"
        prop="srvRefuseRemark"
        min-width="140"
        show-overflow-tooltip
      />
      <el-table-column
        label="服务商审批操作时间"
        align="center"
        prop="srvCheckDt"
        min-width="160"
      />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        fixed="right"
        min-width="120"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['api:getcash:edit']"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['api:getcash:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改用户提现信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="150px">
        <el-form-item label="会员ID" prop="custId">
          <el-input v-model="form.custId" placeholder="请输入会员ID" />
        </el-form-item>
        <el-form-item label="提现人会员号" prop="custNo">
          <el-input v-model="form.custNo" placeholder="请输入提现人会员号" />
        </el-form-item>
        <el-form-item label="提现人姓名" prop="realName">
          <el-input v-model="form.realName" placeholder="请输入提现人姓名" />
        </el-form-item>
        <el-form-item label="联系方式" prop="mobile">
          <el-input v-model="form.mobile" placeholder="请输入联系方式" />
        </el-form-item>
        <el-form-item label="提现金额" prop="amount">
          <el-input v-model="form.amount" placeholder="请输入提现金额" />
        </el-form-item>
        <el-form-item label="固定手续费" prop="tax">
          <el-input v-model="form.tax" placeholder="请输入固定手续费" />
        </el-form-item>
        <el-form-item label="按比例手续费" prop="srvFee">
          <el-input
            v-model="form.srvFee"
            placeholder="请输入按比例手续费  amount * 手续费比率"
          />
        </el-form-item>
        <el-form-item label="实际到帐金额" prop="actualAmount">
          <el-input
            v-model="form.actualAmount"
            placeholder="请输入实际到帐金额 = 申请金额 - 代缴税 - 提现手续费"
          />
        </el-form-item>
        <el-form-item label="提现人身份证号" prop="custCardno">
          <el-input
            v-model="form.custCardno"
            placeholder="请输入提现人身份证号"
          />
        </el-form-item>
        <el-form-item label="收款银行" prop="bankName">
          <el-input v-model="form.bankName" placeholder="请输入收款银行" />
        </el-form-item>
        <el-form-item label="银行卡号" prop="bankCard">
          <el-input v-model="form.bankCard" placeholder="请输入银行卡号" />
        </el-form-item>
        <el-form-item label="银行卡所有者" prop="bankCardUnt">
          <el-input
            v-model="form.bankCardUnt"
            placeholder="请输入银行卡所有者"
          />
        </el-form-item>
        <el-form-item label="审核操作人用户号" prop="userName">
          <el-input
            v-model="form.userName"
            placeholder="请输入审核操作人用户号"
          />
        </el-form-item>
        <el-form-item label="撤销原因" prop="statusErr">
          <el-input v-model="form.statusErr" placeholder="请输入撤销原因" />
        </el-form-item>
        <el-form-item label="审核时间" prop="checkDt">
          <el-input v-model="form.checkDt" placeholder="请输入审核时间" />
        </el-form-item>
        <el-form-item label="银行卡开卡省份" prop="bankProvince">
          <el-input
            v-model="form.bankProvince"
            placeholder="请输入银行卡开卡省份"
          />
        </el-form-item>
        <el-form-item label="银行卡开卡城市" prop="bankCity">
          <el-input
            v-model="form.bankCity"
            placeholder="请输入银行卡开卡城市"
          />
        </el-form-item>
        <el-form-item label="签约唯一编号" prop="employeeId">
          <el-input
            v-model="form.employeeId"
            placeholder="请输入签约唯一编号"
          />
        </el-form-item>
        <el-form-item label="推送到第三方唯一 ID" prop="outTradeNo">
          <el-input
            v-model="form.outTradeNo"
            placeholder="请输入推送到第三方唯一 ID"
          />
        </el-form-item>
        <el-form-item label="关联转账单id" prop="transferId">
          <el-input
            v-model="form.transferId"
            placeholder="请输入关联转账单id"
          />
        </el-form-item>
        <el-form-item label="完成日期" prop="closeDt">
          <!-- <el-input v-model="form.closeDt" placeholder="请输入完成日期" /> -->
          <el-date-picker
            v-model="form.closeDt"
            type="date"
            placeholder="请选择完成日期"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
            style="width: 100%"
          />
        </el-form-item>
        <!-- <el-form-item label="创建时间" prop="createDt">
          <el-input v-model="form.createDt" placeholder="请输入创建时间" />
        </el-form-item>
        <el-form-item label="数据更新版本" prop="version">
          <el-input v-model="form.version" placeholder="请输入数据更新版本" />
        </el-form-item> -->
        <el-form-item label=" 备注" prop="remark">
          <el-input v-model="form.remark" placeholder="请输入 备注" />
        </el-form-item>
        <!-- <el-form-item label=" 账套号" prop="sysAccount">
          <el-input v-model="form.sysAccount" placeholder="请输入 账套号" />
        </el-form-item> -->
        <el-form-item label="结算备注" prop="settRemark">
          <el-input
            v-model="form.settRemark"
            type="textarea"
            placeholder="请输入内容"
          />
        </el-form-item>
        <el-form-item label="服务商审批状态" prop="srvCheck">
          <!-- <el-input
            v-model="form.srvCheck"
            placeholder="请输入服务商审批状态【0 审核中 1 已审核 2 已拒绝】"
          /> -->
          <el-select
            v-model="form.srvCheck"
            clearable
            placeholder="请选择"
            style="width: 100%"
          >
            <el-option
              v-for="dict in dict.type.srv_check"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="服务商拒绝原因" prop="srvRefuseRemark">
          <el-input
            v-model="form.srvRefuseRemark"
            placeholder="请输入服务商拒绝原因"
          />
        </el-form-item>
        <!-- <el-form-item label="服务商审批操作时间" prop="srvCheckDt">
          <el-input
            v-model="form.srvCheckDt"
            placeholder="请输入服务商审批操作时间"
          />
        </el-form-item> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listGetcash,
  getGetcash,
  delGetcash,
  addGetcash,
  updateGetcash,
} from "@/api/djk/financeMgr/withdrawDepositMgr";

export default {
  name: "Getcash",
  dicts: ["srv_check", "sys_cust_type", "recv_type", "processing_status"],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 用户提现信息表格数据
      getcashList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        custNo: null,
        realName: null,
        custType: null,
        mobile: null,
        recvType: null,
        bankCard: null,
        status: null,
        outTradeNo: null,
        closeDt: null,
        createDt: null,
        srvCheck: null,
        srvRefuseRemark: null,
        srvCheckDt: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        custId: [
          { required: true, message: "会员ID不能为空", trigger: "blur" },
        ],
        sysAccount: [
          { required: true, message: " 账套号不能为空", trigger: "blur" },
        ],
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询用户提现信息列表 */
    getList() {
      this.loading = true;
      listGetcash(this.queryParams).then((response) => {
        this.getcashList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        custId: null,
        custNo: null,
        realName: null,
        custType: null,
        mobile: null,
        amount: null,
        tax: null,
        srvFee: null,
        actualAmount: null,
        recvType: null,
        custCardno: null,
        bankName: null,
        bankCard: null,
        bankCardUnt: null,
        status: null,
        userName: null,
        statusErr: null,
        checkDt: null,
        bankProvince: null,
        bankCity: null,
        employeeId: null,
        outTradeNo: null,
        transferId: null,
        closeDt: null,
        createDt: null,
        version: null,
        remark: null,
        sysAccount: null,
        settRemark: null,
        srvCheck: null,
        srvRefuseRemark: null,
        srvCheckDt: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加用户提现信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getGetcash(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改用户提现信息";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            updateGetcash(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addGetcash(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除用户提现信息编号为"' + ids + '"的数据项？')
        .then(function () {
          return delGetcash(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "api/getcash/export",
        {
          ...this.queryParams,
        },
        `getcash_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
